package cn.demo.controller;

import cn.demo.impl.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@RestController
public class PayController {

    @Autowired
    private PayService payService;

    @RequestMapping("pay")
    //测试支付使用
    //public String pay(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    public void pay(HttpServletRequest req, HttpServletResponse resp) throws IOException {

        resp.setContentType("text/html;charset=utf-8");
//        String pay = payService.pay(req,resp);
        String pay = payService.pay(req,resp);

        PrintWriter out = resp.getWriter();
        out.print(pay);
        out.close();
        //return "hello world";
    }
}
